VERSION 5.00
Begin VB.Form main 
   Caption         =   "Logic Analyzer : delabs"
   ClientHeight    =   7830
   ClientLeft      =   60
   ClientTop       =   345
   ClientWidth     =   10470
   Icon            =   "main.frx":0000
   LinkTopic       =   "Form1"
   MaxButton       =   0   'False
   Picture         =   "main.frx":17002
   ScaleHeight     =   7830
   ScaleWidth      =   10470
   StartUpPosition =   2  'CenterScreen
   Begin VB.TextBox Text1 
      Alignment       =   2  'Center
      Appearance      =   0  'Flat
      BackColor       =   &H00400000&
      BorderStyle     =   0  'None
      ForeColor       =   &H00C0FFFF&
      Height          =   285
      Left            =   7920
      Locked          =   -1  'True
      TabIndex        =   23
      Text            =   "uS"
      Top             =   7320
      Width           =   495
   End
   Begin VB.Timer Timer1 
      Enabled         =   0   'False
      Interval        =   2000
      Left            =   3480
      Top             =   7320
   End
   Begin VB.ComboBox Combo2 
      BackColor       =   &H00400000&
      Enabled         =   0   'False
      ForeColor       =   &H00C0FFFF&
      Height          =   315
      ItemData        =   "main.frx":26896
      Left            =   9360
      List            =   "main.frx":268AF
      Style           =   2  'Dropdown List
      TabIndex        =   22
      Top             =   4920
      Width           =   735
   End
   Begin VB.ComboBox Combo1 
      BackColor       =   &H00400000&
      Enabled         =   0   'False
      ForeColor       =   &H00C0FFFF&
      Height          =   315
      ItemData        =   "main.frx":268D4
      Left            =   9360
      List            =   "main.frx":268ED
      Style           =   2  'Dropdown List
      TabIndex        =   20
      Top             =   3720
      Width           =   735
   End
   Begin VB.CommandButton Command5 
      Caption         =   "get"
      Enabled         =   0   'False
      Height          =   255
      Left            =   7920
      TabIndex        =   19
      Top             =   6960
      Width           =   495
   End
   Begin VB.CommandButton Command4 
      Caption         =   "exit"
      Height          =   255
      Left            =   360
      TabIndex        =   13
      Top             =   7440
      Width           =   615
   End
   Begin VB.CommandButton Command3 
      Caption         =   "port"
      Height          =   255
      Left            =   1560
      TabIndex        =   12
      Top             =   7440
      Width           =   615
   End
   Begin VB.VScrollBar VScroll4 
      Enabled         =   0   'False
      Height          =   375
      Left            =   9360
      Max             =   100
      Min             =   -100
      TabIndex        =   11
      Top             =   2160
      Width           =   735
   End
   Begin VB.VScrollBar VScroll3 
      Enabled         =   0   'False
      Height          =   375
      LargeChange     =   10
      Left            =   9360
      Max             =   -10000
      Min             =   10000
      SmallChange     =   100
      TabIndex        =   10
      Top             =   4440
      Width           =   735
   End
   Begin VB.PictureBox Picture1 
      Appearance      =   0  'Flat
      AutoRedraw      =   -1  'True
      BackColor       =   &H00B58242&
      BorderStyle     =   0  'None
      ForeColor       =   &H80000008&
      Height          =   6000
      Left            =   360
      ScaleHeight     =   400
      ScaleMode       =   3  'Pixel
      ScaleWidth      =   557
      TabIndex        =   7
      Top             =   360
      Width           =   8355
   End
   Begin VB.Frame Frame4 
      BackColor       =   &H00404000&
      Caption         =   "Power"
      ForeColor       =   &H0080FFFF&
      Height          =   1335
      Left            =   9240
      TabIndex        =   5
      Top             =   6360
      Width           =   735
      Begin VB.CommandButton Command9 
         BackColor       =   &H00008000&
         Caption         =   "ON"
         Height          =   495
         Left            =   120
         TabIndex        =   6
         Top             =   720
         Width           =   495
      End
      Begin VB.Shape Shape10 
         BackColor       =   &H00008000&
         BackStyle       =   1  'Opaque
         BorderWidth     =   2
         Height          =   255
         Left            =   120
         Shape           =   1  'Square
         Top             =   240
         Width           =   495
      End
   End
   Begin VB.CommandButton Command1 
      Caption         =   "Grid"
      Enabled         =   0   'False
      Height          =   255
      Left            =   9360
      TabIndex        =   4
      Top             =   2880
      Width           =   735
   End
   Begin VB.VScrollBar VScroll2 
      Enabled         =   0   'False
      Height          =   375
      Left            =   9360
      Max             =   -80
      Min             =   50
      TabIndex        =   2
      Top             =   720
      Width           =   735
   End
   Begin VB.VScrollBar VScroll1 
      Enabled         =   0   'False
      Height          =   375
      Left            =   9360
      Max             =   -50
      Min             =   50
      TabIndex        =   0
      Top             =   1440
      Width           =   735
   End
   Begin VB.Label Label10 
      Alignment       =   2  'Center
      BackStyle       =   0  'Transparent
      Caption         =   "zoom"
      ForeColor       =   &H00C0FFFF&
      Height          =   255
      Left            =   9360
      TabIndex        =   21
      Top             =   3480
      Width           =   735
   End
   Begin VB.Shape get_led 
      BackColor       =   &H00000080&
      BackStyle       =   1  'Opaque
      BorderWidth     =   2
      Height          =   135
      Left            =   7920
      Top             =   6720
      Width           =   495
   End
   Begin VB.Label Label9 
      Alignment       =   2  'Center
      BackStyle       =   0  'Transparent
      Caption         =   "5"
      ForeColor       =   &H00C0FFFF&
      Height          =   255
      Left            =   7200
      TabIndex        =   18
      Top             =   7080
      Width           =   375
   End
   Begin VB.Label Label8 
      Alignment       =   2  'Center
      BackStyle       =   0  'Transparent
      Caption         =   "4"
      ForeColor       =   &H00C0FFFF&
      Height          =   255
      Left            =   6840
      TabIndex        =   17
      Top             =   7080
      Width           =   375
   End
   Begin VB.Label Label7 
      Alignment       =   2  'Center
      BackStyle       =   0  'Transparent
      Caption         =   "3"
      ForeColor       =   &H00C0FFFF&
      Height          =   255
      Left            =   6480
      TabIndex        =   16
      Top             =   7080
      Width           =   375
   End
   Begin VB.Shape led5 
      BackColor       =   &H00008080&
      BackStyle       =   1  'Opaque
      BorderWidth     =   2
      Height          =   135
      Left            =   7320
      Top             =   6840
      Width           =   135
   End
   Begin VB.Shape led4 
      BackColor       =   &H00008080&
      BackStyle       =   1  'Opaque
      BorderWidth     =   2
      Height          =   135
      Left            =   6960
      Top             =   6840
      Width           =   135
   End
   Begin VB.Shape led3 
      BackColor       =   &H00008080&
      BackStyle       =   1  'Opaque
      BorderWidth     =   2
      Height          =   135
      Left            =   6600
      Top             =   6840
      Width           =   135
   End
   Begin VB.Label Label6 
      Alignment       =   2  'Center
      BackStyle       =   0  'Transparent
      Caption         =   "2"
      ForeColor       =   &H00C0FFFF&
      Height          =   255
      Left            =   6120
      TabIndex        =   15
      Top             =   7080
      Width           =   375
   End
   Begin VB.Shape led2 
      BackColor       =   &H00008080&
      BackStyle       =   1  'Opaque
      BorderWidth     =   2
      Height          =   135
      Left            =   6240
      Top             =   6840
      Width           =   135
   End
   Begin VB.Shape led1 
      BackColor       =   &H00008080&
      BackStyle       =   1  'Opaque
      BorderWidth     =   2
      Height          =   135
      Left            =   5880
      Top             =   6840
      Width           =   135
   End
   Begin VB.Label Label5 
      Alignment       =   2  'Center
      BackStyle       =   0  'Transparent
      Caption         =   "1"
      ForeColor       =   &H00C0FFFF&
      Height          =   255
      Left            =   5760
      TabIndex        =   14
      Top             =   7080
      Width           =   375
   End
   Begin VB.Label Label4 
      Alignment       =   2  'Center
      BackStyle       =   0  'Transparent
      Caption         =   "v-pos"
      ForeColor       =   &H00C0FFFF&
      Height          =   255
      Left            =   9360
      TabIndex        =   9
      Top             =   1920
      Width           =   735
   End
   Begin VB.Label Label3 
      Alignment       =   2  'Center
      BackStyle       =   0  'Transparent
      Caption         =   "h-pos"
      ForeColor       =   &H00C0FFFF&
      Height          =   255
      Left            =   9360
      TabIndex        =   8
      Top             =   4200
      Width           =   735
   End
   Begin VB.Shape Shape1 
      BackStyle       =   1  'Opaque
      BorderColor     =   &H00400000&
      FillColor       =   &H00400000&
      FillStyle       =   0  'Solid
      Height          =   6255
      Left            =   240
      Top             =   240
      Width           =   8595
   End
   Begin VB.Label Label2 
      Alignment       =   2  'Center
      BackStyle       =   0  'Transparent
      Caption         =   "Beam"
      ForeColor       =   &H00C0FFFF&
      Height          =   255
      Left            =   9360
      TabIndex        =   3
      Top             =   360
      Width           =   735
   End
   Begin VB.Label Label1 
      Alignment       =   2  'Center
      BackStyle       =   0  'Transparent
      Caption         =   "Light"
      ForeColor       =   &H00C0FFFF&
      Height          =   255
      Left            =   9360
      TabIndex        =   1
      Top             =   1200
      Width           =   735
   End
End
Attribute VB_Name = "main"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit
Dim get_time As Double
Dim PC1 As New cPerfCounter 'initialize class reference
Dim pic1_r, pic1_g, pic1_b, grid_flag
Dim h_pitch, v_pitch
Dim beam_color
Dim pos_h, pos_v
Dim port_flag, data_flag, zoom_in, get_flag

Private Sub Combo1_Click()
VScroll3.Value = 0
Picture1.Cls
draw_sweep
draw_grid
End Sub

Private Sub Combo2_Click()
VScroll3.SmallChange = Combo2.Text
End Sub

Private Sub Command1_Click()
If grid_flag = 1 Then
grid_flag = 0
Else
grid_flag = 1
End If
If grid_flag = 1 Then
draw_grid
Else
Picture1.Cls
End If
draw_sweep
End Sub
Private Sub Command3_Click()
If port_flag = 1 Then
port_flag = 0
port.Hide
Else
port_flag = 1
port.Show
End If
End Sub

Private Sub Command4_Click()
unload_me
End Sub

Private Sub Command5_Click()
Timer1.Enabled = True
Command5.Enabled = False
get_led.BackColor = RGB(255, 0, 0)
End Sub

Private Sub Command9_Click()
If Command9.Caption = "ON" Then
Command9.Caption = "OFF"
Shape10.BackColor = RGB(124, 252, 0)
on_all
Else
Command9.Caption = "ON"
Shape10.BackColor = RGB(34, 139, 34)
off_all
End If
End Sub

Private Sub Form_Activate()
Picture1.Cls
draw_grid
End Sub

Private Sub Form_Load()
pic1_r = 70
pic1_g = 130
pic1_b = 180
Picture1.BackColor = RGB(pic1_r, pic1_g, pic1_b)
grid_flag = 1
h_pitch = 40
v_pitch = 40
beam_color = 200
pos_h = 0
pos_v = 0
port.Combo1.Text = "&H378"
Combo1.Text = "001"
Combo2.Text = "100"
zoom_in = Combo1.Text
output_port = port.Combo1.Text
input_port = output_port + 1
control_port = output_port + 2
port_flag = 0
data_flag = 0
get_flag = 0
End Sub

Private Sub Form_Unload(Cancel As Integer)
unload_me
End Sub

Private Sub Timer1_Timer()
Dim time_no
PC1.Reset
time_no = 1
Do Until time_no = samp_no
in_port(time_no) = Inp(input_port)
time_no = time_no + 1
Loop
Text1.Text = Format(PC1.Elapsed * 1000, "000.0")
format_data
main.Picture1.Cls
main.draw_sweep
main.draw_grid
Timer1.Enabled = False
get_led.BackColor = RGB(121, 26, 13)
Command5.Enabled = True
End Sub

Private Sub VScroll1_Change()
pic1_r = 70 + VScroll1.Value
pic1_g = 130 + VScroll1.Value
pic1_b = 180 + VScroll1.Value
Picture1.BackColor = RGB(pic1_r, pic1_g, pic1_b)
Picture1.Cls
draw_grid
Combo1.Text = "010"
draw_sweep
End Sub
Sub draw_grid()
Dim v_pos, h_pos, h_lines, v_lines
h_lines = 10
v_lines = 14
v_pos = 0
h_pos = 0
Picture1.DrawWidth = 1
Picture1.DrawStyle = 0
Do Until h_lines = 0
h_lines = h_lines - 1
Picture1.Line (v_pos, h_pos)-(v_pos + 1000, h_pos), RGB(70, 86, 115)
h_pos = h_pos + v_pitch
Loop
v_pos = 0
h_pos = 0
Do Until v_lines = 0
v_lines = v_lines - 1
Picture1.Line (v_pos, h_pos)-(v_pos, h_pos + 1000), RGB(70, 86, 115)
v_pos = v_pos + h_pitch
Loop
End Sub

Private Sub VScroll2_Change()
beam_color = 200 + VScroll2.Value
Picture1.Cls
Combo1.Text = "010"
draw_sweep
draw_grid
End Sub
Sub draw_sweep()
Dim cnt_up, px_no
zoom_in = Combo1.Text
Picture1.DrawWidth = 2
Picture1.DrawStyle = 0
'
px_no = 1
cnt_up = 1
Do Until cnt_up > samp_no
Picture1.PSet (0 + px_no + pos_h, ch_1(cnt_up) + pos_v), RGB(70, beam_color, 180)
cnt_up = cnt_up + zoom_in
px_no = px_no + 1
Loop
'
px_no = 1
cnt_up = 1
Do Until cnt_up > samp_no
Picture1.PSet (0 + px_no + pos_h, ch_2(cnt_up) + pos_v), RGB(70, beam_color, 180)
cnt_up = cnt_up + zoom_in
px_no = px_no + 1
Loop
'
px_no = 1
cnt_up = 1
Do Until cnt_up > samp_no
Picture1.PSet (0 + px_no + pos_h, ch_3(cnt_up) + pos_v), RGB(70, beam_color, 180)
cnt_up = cnt_up + zoom_in
px_no = px_no + 1
Loop
'
px_no = 1
cnt_up = 1
Do Until cnt_up > samp_no
Picture1.PSet (0 + px_no + pos_h, ch_4(cnt_up) + pos_v), RGB(70, beam_color, 180)
cnt_up = cnt_up + zoom_in
px_no = px_no + 1
Loop
'
px_no = 1
cnt_up = 1
Do Until cnt_up > samp_no
Picture1.PSet (0 + px_no + pos_h, ch_5(cnt_up) + pos_v), RGB(70, beam_color, 180)
cnt_up = cnt_up + zoom_in
px_no = px_no + 1
Loop
'
End Sub

Private Sub VScroll3_Change()
Picture1.Cls
pos_h = VScroll3.Value
draw_sweep
draw_grid
End Sub

Private Sub VScroll4_Change()
Picture1.Cls
pos_v = VScroll4.Value
Picture1.Cls
Combo1.Text = "010"
draw_sweep
draw_grid
End Sub
Sub on_all()
Dim cnt_no
VScroll1.Enabled = True
VScroll2.Enabled = True
VScroll3.Enabled = True
VScroll4.Enabled = True
Command1.Enabled = True
Command5.Enabled = True
Combo1.Enabled = True
Combo2.Enabled = True
cnt_no = 1
Do Until cnt_no = samp_no
ch_1(cnt_no) = ch1_lo
cnt_no = cnt_no + 1
Loop
cnt_no = 1
Do Until cnt_no = samp_no
ch_2(cnt_no) = ch2_lo
cnt_no = cnt_no + 1
Loop
cnt_no = 1
Do Until cnt_no = samp_no
ch_3(cnt_no) = ch3_lo
cnt_no = cnt_no + 1
Loop
cnt_no = 1
Do Until cnt_no = samp_no
ch_4(cnt_no) = ch4_lo
cnt_no = cnt_no + 1
Loop
cnt_no = 1
Do Until cnt_no = samp_no
ch_5(cnt_no) = ch5_lo
cnt_no = cnt_no + 1
Loop
draw_grid
draw_sweep
End Sub

Sub off_all()
VScroll1.Enabled = False
VScroll2.Enabled = False
VScroll3.Enabled = False
VScroll4.Enabled = False
Command1.Enabled = False
Command5.Enabled = False
Combo1.Enabled = False
Combo2.Enabled = False
Picture1.Cls
draw_grid
End Sub
Sub unload_me()
Beep
off_all
Out output_port, output_state 'set ports to default
Out control_port, control_state
Unload port
End
End Sub
Private Sub format_data()
Dim time_no
'ch1
time_no = 1
Do Until time_no = samp_no
sel_bit = in_port(time_no) And sel_hex
If sel_bit = sel_hex Then
ch_1(time_no) = ch1_hi
Else
ch_1(time_no) = ch1_lo
End If
time_no = time_no + 1
Loop
If ch_1(samp_no - 1) = ch1_hi Then
led1.BackColor = RGB(255, 255, 68)
Else
led1.BackColor = RGB(122, 124, 37)
End If
'ch2
time_no = 1
Do Until time_no = samp_no
pe_bit = in_port(time_no) And pe_hex
If pe_bit = pe_hex Then
ch_2(time_no) = ch2_hi
Else
ch_2(time_no) = ch2_lo
End If
time_no = time_no + 1
Loop
If ch_2(samp_no - 1) = ch2_hi Then
led2.BackColor = RGB(255, 255, 68)
Else
led2.BackColor = RGB(122, 124, 37)
End If
'ch3 this bit to be inverted
time_no = 1
Do Until time_no = samp_no
busy_bit = in_port(time_no) And busy_hex
If busy_bit = busy_hex Then
ch_3(time_no) = ch3_lo
Else
ch_3(time_no) = ch3_hi
End If
time_no = time_no + 1
Loop
If ch_3(samp_no - 1) = ch3_hi Then
led3.BackColor = RGB(255, 255, 68)
Else
led3.BackColor = RGB(122, 124, 37)
End If
'ch4
time_no = 1
Do Until time_no = samp_no
ack_bit = in_port(time_no) And ack_hex
If ack_bit = ack_hex Then
ch_4(time_no) = ch4_hi
Else
ch_4(time_no) = ch4_lo
End If
time_no = time_no + 1
Loop
If ch_4(samp_no - 1) = ch4_hi Then
led4.BackColor = RGB(255, 255, 68)
Else
led4.BackColor = RGB(122, 124, 37)
End If
'ch5
time_no = 1
Do Until time_no = samp_no
err_bit = in_port(time_no) And err_hex
If err_bit = err_hex Then
ch_5(time_no) = ch5_hi
Else
ch_5(time_no) = ch5_lo
End If
time_no = time_no + 1
Loop
If ch_5(samp_no - 1) = ch5_hi Then
led5.BackColor = RGB(255, 255, 68)
Else
led5.BackColor = RGB(122, 124, 37)
End If
End Sub

